<?php


namespace app\handler;


class Param
{
    public function userParam($param, $query)
    {
        if (!empty($param['name'])) {
            $query->where('name', 'like', "%{$param['name']}%");
        }


        return $query;
    }
    public function vegetablesParam($param, $query)
    {
        if (!empty($param['name'])) {
            $query->where('name', 'like', "%{$param['name']}%");
        }
        if (!empty($param['day'])) {
            $query->where('day', $param['day'] );
        }
        return $query;
    }

    public function newsParam($param, $query)
    {
        if (!empty($param['type'])) {
            $query->where('type', $param['type'] );
        }
        return $query;
    }

    public function informationParam($param, $query)
    {
        if (!empty($param['user_id'])) {
            $query->where('user_id', $param['user_id']);
        }
        if (!empty($param['to_user_id'])) {
            $query->where('to_user_id', $param['to_user_id'] );
        }
        return $query;
    }
}